package com.woniu.darryringmall.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.darryringmall.admin.entity.CensusVO;
import com.woniu.darryringmall.admin.entity.CommentVO;
import com.woniu.darryringmall.admin.service.CensusVoService;
import com.woniu.darryringmall.admin.service.CommentVoService;
import com.woniu.darryringmall.front.entity.Comment;
import com.woniu.darryringmall.utils.ResponseData;
import com.woniu.darryringmall.utils.ResultStateCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("adminComment")
@RequestMapping("admin/commentvo")
public class CommentVoController {
    @Autowired
    private CommentVoService commentVoService;

    @Autowired
    private CensusVoService censusVoService;

    @GetMapping("list/{current}")
    public ResponseData<Page<CommentVO>> commentList(@PathVariable("current") int current){
        Page<CommentVO> page = new Page<>(current,5);
        Page<CommentVO> result = commentVoService.page(page, null);
//        List<Comment> list = result.getRecords();
        ResponseData<Page<CommentVO>> data = new ResponseData<>(ResultStateCode.SUCCESS,"");
        data.setData(result);
        return data;
    }

    @GetMapping("census")
    public ResponseData<List<CensusVO>> census(){
        List<CensusVO> list = censusVoService.list();
        ResponseData<List<CensusVO>> data = new ResponseData<>(ResultStateCode.SUCCESS,"");
        data.setData(list);
        return data;
    }

}
